<?php

/*
 * 
 * 
 */
$start = microtime(true);
define('ABSPATH', dirname(__FILE__) . '/');
if (function_exists('xdebug_start_trace')) {
    //xdebug_start_trace(ABSPATH . 'trace.xt' . uniqid());
}
set_time_limit(0);
ob_implicit_flush(true);
require_once('include.all.php');

$results = array();
for($i = 0; $i < 10; $i++) {
    $results[] = Ajax('http://ya.ru', array(
        'actions' => array(
            new MakeQueryAfterTime(),
            new FilterByContent(function($content) {
                var_dump('FilterByContent ' . strlen($content));
                var_dump('FilterByContent </html> ' . strpos($content, '</html>'));
                return true;
            })
        )
    ));
    
}
$def = new DeferredList($results);
$def->addBoth(function($results) {
    foreach ($results as $result) {
        var_dump($result['url'].' '.strlen($result['result']));
    }
});


Tick::getInstance()->startExecution();

echo 'end: ' . (microtime(true) - $start);
//register_shutdown_function
//register_tick_function